<template>
  <li>
    <input type="checkbox" :checked="completed" @change="toggleCompletion" />
    <span :style="{ textDecoration: completed ? 'line-through' : 'none' }">{{ title }}</span>
    <button @click="removeTodo">删除</button>
  </li>
</template>

<script>
export default {
  name: 'TodoItem',
  props: {
    title: {
      type: String,
      required: true
    },
    completed: {
      type: Boolean,
      required: true
    }
  },
  methods: {
    toggleCompletion() {
      this.$emit('update:completed', !this.completed);
    },
    removeTodo() {
      this.$emit('remove-todo');
    }
  }
}
</script>

<style scoped>
li {
  display: flex;
  align-items: center;
  margin: 5px 0;
}
input[type="checkbox"] {
  margin-right: 10px;
}
button {
  margin-left: 10px;
  padding: 5px 10px;
}
</style>